home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Textfiles / cracking / RealmzCrack.txt < prev    next >
Text File  |  1998-08-07  |  23KB  |  325 lines

  1. Cracking '96 - An Introduction, using Realmz
  2.  
  3. by  The Morrin Hackers
  4.  
  5. edited and with annotations by Mr. Wood
  6.  
  7. for educational purposes only ;)
  8.  
  9. Part One:
  10.  
  11. Cracking Realmz, the Game registration only.
  12.  
  13.  
  14. Introduction: 
  15.  
  16. This is a quick tutorial to crack Realmz 3.0.1. It shows basic assembly and some simple cracking ideas in 1996. The Crack is by Morrin Hackers, as is this document. With all due respect to Fantasoft, the creators of Realmz, it is a great game; I cracked it and wrote this document for educational purposes, ie. for other people to learn some of the basics. Thank Fantasoft for creating such an easily hackable product that has given people hours of cracking enjoyment. :)
  17.  
  18.  
  19. The Equipment: (Hardware and Software)
  20.  
  21. Basic Stuff:
  22.     Ä You need a Macintosh, either a 68xxx or PPC will do
  23.     Ä Realmz 3.0.1, available from shareware.com
  24.     
  25. Hacking/Cracking Stuff:
  26.     Ä ResEdit: (and the Code Viewer for it) The combination of these two is     sometimes known as SuperResEdit. The CodeViewer enables you to view the Code Resource of a file as assembly instructions. ResEdit is simply a resource editor and documentation can be found at Apple's Web site. (Both the documentation for ResEdit and ResEdit itself are free.)
  27.     Ä MacsBug: This is a very good debugging program which can also be found at Apple's web sites, as can documentation for it, although there is some built in. [the current version is 6.5.3]
  28.  
  29.  
  30.  
  31. The Brains: (Wetware)
  32.  
  33. For all cracking of this type you really need to know some assembly. Some documentation can, again, be found at Apple's Web sites, but the best introduction to it is, imho, "Assembly for cracking" by The Shepherd. It's not easy to get hold of, or wasn't when I got it, but you should be able to obtain a copy via a request in alt.hackintosh, however I have made quick explanations whenever I've dealt with it in this document, so you will be able to learn a bit from just reading this.
  34.  
  35. [ed note:  Besides The Shepherd, mentioned above, there seem to be scant few tutorials on cracking the Mac, a truly sad reflexion on this fascinating subject.  The Observer, for one, has written a series of excellent articles describing introducory crack methods. These are documented in "Basic Mac Cracking I - IV", as well as in a cameo bit in the MacHackFAQ v.2.0.  However, as this person is very fond of Resorcerer, a $256 program, to do his work with, I feel that a how-to manual using freely available tools is in order.  I'm sure  owning Resorcerer is very nice and all, and someday, if I can justify buying it, I will, but for now I just can't afford it. Another excellent source is "How to Crack" (also known as "[k]") by The Vassal.  This is rather old, as is The Shepherd's info, but even though the tools have changed the methods are still useful.]
  36.  
  37. Another note to make is: Realmz not PPC native, it is therefore not in PPC assembly, but 68k instead.
  38.  
  39.  
  40. The Crack:
  41.  
  42. Firstly: The secret to all types of hacking is to understand a system, so as then to be able to manipulate it in a way that you want. 
  43.  
  44. 1)     So we need to understand the system. 
  45.  
  46. [ed note: This reflects straight back to the comments on assembly above. To crack, one is taking the guts of a program and reworking them to suit your purposes. As such, one must have at least a certain understanding of what is going on in those same guts. Without some basic understanding of algorithms, programming and assembly language, following the directions of someone else's crack (or worse, using Hack It or some similar patch program to do the work for you), is nothing more than an excercise in paint-by-numbers, or fill in the blanks. No guts, no glory.]
  47.  
  48. 1.0.0) Open realmz. You will see that it brings up a dialog box with a register button at the bottom.
  49. 1.0.1) Click on the Register button. You'll see that nothing happens as we have not yet entered anything. 
  50. 1.0.2) Type in a number and press the button again. So once you've done this we continue to analyze the system. It then brings up a dialog box asking for a name. This *usually* indicates that there is a relationship between the name and the number. (I must admit that in this case no such relationship exists)
  51. 1.0.4) You should type in your name and see what it does. It should then give you an error message saying that you've made a mistake.
  52.  
  53. 1.1.0) We'll now try to figure out where in the code all this is happening by using MacsBug.
  54. 1.1.1) Press Command-reset (that's the Apple key and the funny triangle key). You should have jumped into MacsBug now, if you have you'll see a big white box and lots of numbers and lines.
  55. 1.1.2) Type 'help' then the <return> key to get used to the text interface and then play with it a bit.
  56. 1.1.3) Type 'atb GetDialogItemText' [no quotes] then the <return> key. This will set what is called a trap, you will be thrown into MacsBug whenever a GetDialogItemText function is called, note that whenever you want to get text from a dialog, the programmer uses this procedure. 'How do you     know that?' I hear you cry, I know because I program. :)  But     seriously: Apple have created loads of these and they often create the backbone for cracking with MacsBug. Type 'g' then the <return> key to return to normal. You'll probably notice that everything has slowed down a bit, it's alright, it's just MacsBug.
  57. 1.1.4) Why are we doing this? The answer is: we are trying to find out what is going on in the code when reamz gets your registration number. To do this we need to intercept the program when it finds out what we typed, this is exactly what MacsBug is going to do.
  58. 1.1.5) Type in anything you want into the registration number and press the register button.
  59. 1.1.6) You should have jumped into MacsBug again. This is because Realmz tried to use the GetDialogItemText function. Now's where knowing MacsBug comes in important. You need to know what is going on. If your totally new to it you'd better skip to the back and read up on MacsBug, if you know a bit read on! Now we are in the program we need to know where, so check out the offset and code resource we're on and write it down an a piece of paper.
  60. 1.1.7) Type: 'atc' and then press the <return> key. This will clear all traps. a Trap is a fancy word for what we did earlier, but it's also a descriptive word, we traped the program when it tried to call the GetDialogItemText function. MacsBug calles that a trap, so what we do when we type: 'atc' is  clear the trap so we dont accidentally jump back into MacsBug again. This will also speed up everything as MacsBug wil no longer have to check every instruction to see if it's a GetDialogItemText function.
  61. 1.1.8) Now we are going to use the trace and step commands. Type 't' to trace, this will make you execute the current instruction and then go to the next one without entering any procedures, there is another similar instruction: the 's' instruction which will take you into a procedure. Basically when you press 't' on a ToolBox Instruction( like the GetDialogItemText function we just cleared the trap for) instruction it will not enter the code(it will jump over the instruction) where the 's' - step command - will jump into the instruction if possible, so in the above example of a toolbox instruction you will enter the code for that toolbox instruction, in stead of jumping over it if you had pressed 's', but you should have pressed 't', so we have traced over it.
  62. 1.1.9) Type 't' until you get to a 'BNE' or 'BEQ' instruction. ('t' traces through the program)
  63. 1.1.10) You should have noticed that when a 'jsr' instruction was traced over MacsBug took a little longer than normal, why? This is because a JSR instruction is an instuction that actually executes a whole chunk of code. It will, just like a ToolBox function, be stepped over, and also like a toolBox Function you can step into it will the step command. The JSR command will execute a whole series of instuctions, usually this is used to do a specific task, like to draw a circle. One thing else to note is unlike a ToolBox function you can set traps for these because the programmer makes them.
  64. 1.1.11) Note down the offset of the BNE or BEQ instuction, and whether the program will branch or not. Thats what a branch statement is for, if a condition is true the program will branch off to another place, else it will continue. MacsBug tells you just above the command-line, whether the program is about to branch or continue, it is this which you will have to note down.
  65. 1.1.12) Here's an assembly note: 'BNE' stands for Branch if not equal to, this means that the program checks if the last instruction was equal to zero, if wasn't then it jumps, else it continues. This type of instruction is very commonly used to check registration numbers and so on. Another very similar instruction is BEQ, this stands for Branch_if_EQual_to, this means that if the last instruction was equal to zero then it will branch, otherwise continue.
  66. 1.1.13) The fisrt BEQ or BNE instruction you find should look like this:
  67.     +024B0 00BA1810   BEQ        'CODE 0009 15AC'+023BA     ; 00BA171A   | 6700 FF08
  68.     and it should say that the program will not branch. Notice that the instruction above the BEQ is: 'tst.w' you can ignore the '.w' as it refers to what part of a series of bits is being acted upton. But the 'tst' part is interesting as it is a test instruction. In this case it is testing the length of the registration number you just typed in, you should be able to guess this from seeing the instruction above the åtstπ instruction, the toolBox function: StringWidth which gets the length of a string. So we know exactly what is going on.
  69. 1.1.14) You should continue to use the trace command until you get given the error message about the registration, then you can type in 'g' to continue. Remember to keep track of what is going on by using paper to note down offsets and the other stuff I told you too earlier. 
  70. 1.1.15) I thought I'd mention this beacause of what I was saying about JSR instructions: You should have noticed that when you got to offset: '025F4' you find  ≥JSR        'CODE 0008 15AC'+00654≤ and when you trace over it you find your self entering your name in to a dialog box in realmz. This procedure(CODE 0008 at 00654) is a procedure specially for you to type in your name) - now you can see more exactly how jsr instructions work.
  71. 1.1.16) This is just a note that you should find one BNE at 2642 (in code 9). If you want to see roughly what happened and what you should have check out the back: I've got it all written down.
  72.  
  73.  
  74. 2. We now understand  the system, so itπs t ime to get our hands dirty with some actual alterations! This is step two in hacking, once we understand a system we manipulate it.
  75.  
  76. 2.0.1) Now we have enough data on where the program goes in these branch statements to start with ResEdit, so open Realmz(the game) in resEdit.
  77. 2.0.2) We now need to remember what happened when, and so what you've been writing down is essential. Open the Code set of resources, and then the code 9 resource. Once that is open scroll down to the offset we found the GetDialogItemText.(note that in the ResEdit code Viewer it is written as: GetItText - This doesn't really matter) You may be wondering why I opened the CODE resource, the answer is: all 68k programs have there code in Code resources, and I'm afraid that I have found this out because I program, but it's more or less obvious if you've hacked much in the past. (not that you have :) Another interesting thing is that: PPC programs don't store there code in a resource at all, but instead they do it in teh dta fork of a file. 
  78. 2.0.3) Start tracing through the code with your eyes, and check to see that what you wrote down was correct. If we think about it, one of the branch instructions before the error dialog was displayed must have been the check to see if you typed in the right code. Therefore we're going to do some fiddling. But before we do this there is a little problem with the format of ResEdit compared to that of MacsBug, I've documented it at the back because it's quite complicated so if you're unfamiliar with the difference check that out.
  79. 2.0.4) Go to the Second branch instruction that you found and change it to the opposite type of instruction(BNE -> BEQ and BEQ -> BNE). Remember the first one, we figured out, was just to check the length of your registration number. To do this you'll have to open the hex editor, after selecting the appropriate hex instruction on the far right of the Code Viewer window. The change is in fact very simple; the BNE instruction is 66xx and the BEQ instruction is 67xx. [Note that selecting an instruction is done in the code viewer, where the disassembled code is placed next to its hex and ascii equivalents. When opening the Hex Editor, this selection is automatically transferred, so changes can be made, and the changes are also automatically sent back]
  80. 2.0.5) Save and quit. then test the program. You don't get quite the desired result, but you do find out more about how the program works.
  81. 2.0.6) Go through all the branches, one at a time, changing the next and fixing the last one, then testing the program. This is slow but almost always bound to work.
  82. 2.0.7) You should find that when you get to BNE at 2642 (in code 9) and no other change is made that whatever happens the game is registered! Yes this is it, a game cracked, and all you had to do was change about a 67 and 66. 
  83.  
  84.  
  85. So how's that? Realmz cracked in 2 stages.  ;-)
  86.  
  87. The purpose of this is not to crack Realmz as much as to learn how to crack, which I hope this has helped you to do. Thanks to: Mr. Wood for Editing and Thanks to Fantasoft for making the game.
  88.  
  89.  
  90. MacsBug Sample Data
  91.  
  92. Here is my smaple data for the use of MascBug in part 1.1:
  93.  
  94.  
  95.  All A-Traps actions cleared
  96. Step (over)
  97.   'CODE 0009 15AC'
  98.      +02494 00BA17F4   _GetDialogItemText                    ; 40886948
  99.      +02496 00BA17F6   MOVE.L     #$00E98E9E,-(A7)
  100.      +0249C 00BA17FC   PEA        -$0008(A6)
  101.      +024A0 00BA1800   JSR        'CODE 000F 15AC'+02854
  102.      +024A4 00BA1804   CLR.W      -(A7)
  103.      +024A6 00BA1806   MOVE.L     #$00E98E9E,-(A7)
  104.      +024AC 00BA180C   _StringWidth                          ; 0018D1D0
  105.      +024AE 00BA180E   TST.W      (A7)+
  106.      +024B0 00BA1810   BEQ        'CODE 0009 15AC'+023BA     ; 00BA171A
  107. above Will Not Branch
  108.      +024B4 00BA1814   CMPI.L     #$0000038F,-$0008(A6)
  109.      +024BC 00BA181C   BNE        'CODE 0009 15AC'+025F0     ; 00BA1950
  110. above Will Branch
  111.      +025F0 00BA1950   MOVE.W     #$0001,-(A7)
  112.      +025F4 00BA1954   JSR        'CODE 0008 15AC'+00654
  113. above Gets user Name
  114.      +025F8 00BA1958   MOVE.L     $00E95114,$00E96C48
  115.      +02602 00BA1962   MOVEQ      #$18,D0
  116.      +02604 00BA1964   MOVE.L     $00E96C48,D1
  117.      +0260A 00BA196A   DIVS.L     D0,D1
  118.      +0260E 00BA196E   MOVE.L     D1,$00E96C48
  119.      +02614 00BA1974   MOVEQ      #$18,D0
  120.      +02616 00BA1976   ADD.L      D0,$00E96C48
  121.      +0261C 00BA197C   MOVEQ      #$0F,D0
  122.      +0261E 00BA197E   MULU.L     $00E96C48,D0
  123.      +02626 00BA1986   MOVE.L     D0,$00E96C48
  124.      +0262C 00BA198C   SUBI.L     #$00000100,$00E96C48
  125.      +02636 00BA1996   MOVE.L     -$0008(A6),D0
  126.      +0263A 00BA199A   CMP.L      $00E96C48,D0
  127.      +02640 00BA19A0   ADDQ.L     #$2,A7
  128.      +02642 00BA19A2   BNE        'CODE 0009 15AC'+026F8     ; 00BA1A58
  129. above Will Branch
  130.      +026F8 00BA1A58   MOVE.L     #$00E98E9E,-(A7)
  131.      +026FE 00BA1A5E   MOVE.L     #$00010003,-(A7)
  132.      +02704 00BA1A64   JSR        'CODE 000F 15AC'+02890
  133.      +02708 00BA1A68   MOVE.L     #$00E98E9E,-(A7)
  134.      +0270E 00BA1A6E   MOVE.L     #$00021772,-(A7)
  135.      +02714 00BA1A74   JSR        'CODE 000F 15AC'+02890
  136.      +02718 00BA1A78   MOVE.L     #$01901770,-(A7)
  137.      +0271E 00BA1A7E   MOVE.L     #$00320096,-(A7)
  138.      +02724 00BA1A84   MOVE.L     #$00E98E9E,-(A7)
  139.      +0272A 00BA1A8A   JSR        'CODE 0005 15AC'+0235A 
  140. above Puts up failed Dialog.
  141.  
  142.  
  143. MacsBug to ResEdit Formating
  144.  
  145. The Difference in format from MacsBug to ResEdit:
  146.  
  147. In MacsBug an instruction is shown:
  148. OffSet           Instr      Where the branch is going
  149. +024B0 00BA1810   BEQ        'CODE 0009 15AC'+023BA     ; 00BA171A
  150.  
  151. In ResEdit's CodeViewer:
  152.          OffSet      Instr                  Where the branch is going
  153. +00130   000024B0    BEQ     Anon2+$0226   ;000023BA
  154.  
  155.  
  156. Some Assembly:
  157.  
  158.   Hex Number  |  Instruction  |  What it does                                                    
  159. -------------------------------------------------------------------------
  160.   66xx xxxx        BNE        (Branch if Not Equal) Branches to the
  161.                      number specified if the last result was not
  162.                     equal to zero
  163.                                  
  164.   67xx xxxx        BEQ        (Branch if EQual) Branches to the instruction
  165.                     if the result of the last instruction was 
  166.                     equal to zero.
  167.                                  
  168.   60xx xxxx        BRA        (BRAnch) Simply branches.
  169.  
  170. One thing that confuses many peoplel is that often when you have an instruction you get after it a fullstop then an 's' or a '.w' and so on. What this is doing is usually not very important to the cracker (imho) but to those no progarmmer minded: this is telling the computer to only use sertain bits when we jump. the '.s' indicates hwat is called the word length, but anless you want to get neck deep in assembly and programming you can ignore all these bits.
  171.  
  172. There are many other branch instructions, most of most of then beginning with '6', but you can find those by experimenting with resEdit. Have fun!
  173.  
  174.  
  175. Some Help with MacsBug:
  176.  
  177. MacsBug is very complicated for those unused to it, but it is also one of the most powerful and simple to use programs for those who understand it, kind of like life...
  178. Anyway: Here's the Basics, 
  179. 1) at the very bottom of the screen is the command line, everything ou type is written here untill you press return at which point it is executed.
  180.  
  181. 2) the box directly above the command line is the program state and contains the current possition in the programs code. You will see four line. The top one indicates the current possition of the program in it's code. If you're running a 68k program you will see something like: 'CODE 9 something' you can ignore the something, but the 'code 9' bit os important. the 'code' bit tells you that you are in a code resource, and the '9' bit tells you thge ID of the resource, in the above case it's CODE resource ID 9. 
  182.  
  183. The three Bottom lines conatin the three next instructions to be executed, Where the top one with the '*' next to it will be executed next.
  184.  
  185. 3) the Boxes on the left give you information about the current program's state and some further info on registers, but you can for now ignore all this.
  186.  
  187. 4) the largest Box is the one above the Program State is the display area, anything that happens is told to you here, if you find yourself unexpectedly launched into macsBug It'll tell you why here. This is also wher you read the help from.
  188.  
  189. Using MacsBug:
  190.  
  191. The Basic commands you'll need to know are: 
  192.  
  193. 1) Trace: type 't' then the <return> key to trace through some code. This will execute the current instuction and go to the next one IN THE SAME PROCEDURE, so that you wont change  your current procedure anless the current insturction will not return to the smae proceudure, in this case it simply take you to the next instruction.
  194. 2) Step: type 's' then the <return> key this is exactly the same as the above instruction exept that it will jump to the next instruction whether or not it leads to another proceudre which returns.
  195.  
  196. 3) Go: type 'g' then the <return> to continue with whatever happend before you were thrown into MacsBug.
  197.  
  198. 4) Escape to Finder: type 'es' then the <return> and you will be put back to the finder just as if you force quit the application.
  199.  
  200. 5) Cleat All Traps: type 'atc' then the <return> to clear al set traps. A trap is just a method to make youself jump into MacsBug whenever a program trys to do something like bring up a dialog box.
  201. Part Two:
  202.  
  203. The Realmz  3.0.1  Registration Crack
  204.  
  205.  
  206. Basic Data
  207.  
  208. Change Resource:
  209.  
  210. Type: CODE
  211.  
  212. Resource Number: 9
  213.  
  214. Line: 2642
  215.  
  216. From:        548F 6600 00B4 2F3C
  217.           
  218. To:        548F 6700 00B4 2F3C
  219.            
  220.  
  221. How To:
  222.  
  223. 1) Open Realmz in ResEdit.
  224.  
  225. 2) Open the 'CODE' type resource ID 9.
  226.  
  227. 3) change line 2642 to   548F 6700 00B4 2F3C.
  228.  
  229.  
  230.  
  231. What its doing:
  232.  
  233. As looked at with ResEdit + CodeViewer, you are changing a resource at
  234.  
  235. Type: CODE
  236. Resource ID: 9
  237. Module: Anon7
  238. Offset: +3DE from Anon7 or 2642 from the start of the resource
  239.  
  240. The original line, before it was cracked, was:
  241.  
  242. | Anon7 Offset | Code Offset | Instruction | Data        | Where Its going |
  243. | +03DE        | 2642        | BNE         | Anon16+$494 | 26F8            |
  244.  
  245.  
  246. The line as cracked, is
  247.  
  248. | Anon7 Offset | Code Offset | Instruction | Data        | Where Its going |
  249. | +03DE        | 2642        | BEQ         | Anon16+$494 | 26F8            |
  250.  
  251. So what's the difference???
  252.  
  253. The difference is BNE has been changed to BEQ.
  254.  
  255. BNE means jump if the last compared data was Not Equal to zero (btw - the last compared data is your password and the password you *should* have typed in). What's going on is that Realmz has just got your password and compared it to what it should be. Realmz then checks to see if they are equal, and jumps to the appropriate place.
  256.  
  257. So,if you typed in the right reg number, realmz continues to the bit of code where you register the game. 
  258.  
  259. But, if you got it wrong, then it jumps, and puts up the error message etc.
  260.  
  261. What we did was simply to change the Branch_if_Not_Equal_to command to a Branch_if_EQual_to command, that way it doesn't matter what you typed, it will register the scenario anyway provided you typed in the wrong number.
  262.  
  263.  
  264.  
  265. Part Three:
  266.  
  267. The Realmz  3.0.1 Scenario Crack
  268.  
  269.  
  270. Basic Data:
  271.  
  272. Change Resource:
  273.  
  274. Type: CODE
  275.  
  276. Resource Number: 7
  277.  
  278. Line: 2C10
  279.  
  280. From:        69FE 6726 3F3C 004E
  281.  
  282. To:        69FE 6026 3F3C 004E
  283.  
  284.  
  285. How To:
  286.  
  287. 1) Open realmz in ResEdit.
  288.  
  289. 2) Open the 'CODE' type resource ID 7.
  290.  
  291. 3) change line 2C10 to 69FE 6026 3F3C 004E.
  292.  
  293.  
  294.  
  295. What its doing:
  296.  
  297. As looked at with ResEdit + CodeViewer, you are changing a resource at
  298.  
  299. Type: CODE
  300. Resource ID: 7
  301. Module: Anon7
  302. Offset: +D7A in Anon7,  or 2C12 from the start of the resource
  303.  
  304. The original line, before it was cracked:
  305.  
  306. | Anon7 Offset | Code Offset | Instruction | Data        | Where Its going |
  307. | +D7A         | 2C12        | BEQ.S       | Anon7+DA2   | 2C3A            |
  308.  
  309. The line as cracked:
  310.  
  311. | Anon7 Offset | Code Offset | Instruction | Data        | Where Its going |
  312. | +D7A         | 2C12        | BRA.S       | Anon7+DA2   | 2C3A            |
  313.  
  314. So what's the difference???
  315.  
  316. The difference is BEQ.S has been changed to BRA.S
  317.  
  318. BEQ.S means jump if the last compared data was EQual (btw - the last compared data is your password and the password you *should* have typed in). What's going on is that Realmz has just got you password and compared it to what it should be. Realmz then checks to see if they are equal (uses a CMP.L command) 
  319.  
  320. So, if you typed in the right password, they are equal, and Realmz jumps to the bit of code where you register the scenario. 
  321.  
  322. But, if you got it wrong, then it doesn't jump, and instead continues, putting up the error message etc.
  323.  
  324. What we did was simply to change the Branch_if_EQual_to command to a simple BRAnch command, that way it doesn't matter what you typed, it will register the scenario anyway.
  325.